package com.yzy.domain.strategy.service.rule.chain.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.yzy.domain.strategy.service.armory.IStrategyDispatch;
import com.yzy.domain.strategy.service.rule.chain.AbstractLogicChain;
import com.yzy.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import com.yzy.domain.strategy.service.rule.chain.factory.DefaultChainFactory.LogicModel;
import com.yzy.types.common.Constants;
import com.yzy.types.common.Constants.RuleKey;

import lombok.extern.slf4j.Slf4j;

/**
 * @author yangzhenyu05 <yangzhenyu05@kuaishou.com>
 * Created on 2024-01-22
 * @description 默认责任链
 */
@Slf4j
@Component(RuleKey.DEFAULT)
public class DefaultLogicChain extends AbstractLogicChain {
    @Resource
    protected IStrategyDispatch strategyDispatch;

    @Override
    protected String ruleModel() {
        return LogicModel.RULE_DEFAULT.getCode();
    }

    @Override
    public DefaultChainFactory.StrategyAwardVO logic(String userId, Long strategyId) {
        Integer awardId = strategyDispatch.getRandomAwardId(strategyId);
        log.info("抽奖责任链-默认处理 userId: {} strategyId: {} ruleModel: {} awardId: {}", userId, strategyId,
                ruleModel(), awardId);
        return DefaultChainFactory.StrategyAwardVO.builder()
                .awardId(awardId)
                .logicModel(ruleModel())
                .build();
    }
}
